package org.ysh.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.ysh.core.annotation.ResourceEx;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@ToString
public class Resource extends BaseEntity{

    public static int RESOURCE_TYPE_MENU = 0;
    public static int RESOURCE_TYPE_BUTTON = 1;
    public static int RESOURCE_TYPE_OTHER = 2;

    // 资源名称
    private String resourceName;
    // 资源编码
    private String resourceCode;
    // 资源描述
    private String resourceDesc;

    // 资源级别 1 一级 2 二级 3 三级
    private Integer level;

    // 状态 0 正常 1 禁用
    private Integer status;
    // 父级code
    private String parentCode;
    // 路径
    private String url;
    // 排序
    private Integer sort;
    // 类型 0 菜单 1 按钮 2 其他
    private Integer type;
    // 图标
    private String icon;
    // 权限
    private String permission;

    private List<Resource> children;

    public Resource() {

    }

    public Resource(ResourceEx ex) {
        this.resourceCode = ex.code();
        this.resourceName = ex.name();
        this.resourceDesc = ex.description();
        this.parentCode = ex.parentCode();
        this.sort = ex.sort();
        this.type = ex.type();
        this.icon = ex.icon();
        this.permission = ex.permission();
    }

}
